<template>
  <div :class="getComponentClass('sh-annex-big')">
    <sh-title class="ivu-pb" :prefix="false" v-if="bigCategoryItem.pCategoryName">{{
      bigCategoryItem.pCategoryName
    }}</sh-title>
    <div class="sh-annex-big-wrapper">
      <template v-for="item in bigCategoryData.data.subCategoryList" :key="item.categoryCode">
        <template v-if="item.categoryCode">
          <annex-sub-category
            :sub-category-item="item"
            :attachmentConfigs="attachmentConfigs"
            :beforeUpload="beforeUpload"
            :beforeDelete="beforeDelete"
            @openProview="e => emits('openProview', e)"
            @uploadSuccess="uploadSuccess"
            @deleteSuccess="deleteSuccess"
          />
        </template>
      </template>
    </div>
  </div>
</template>

<script setup>
import { useClass } from '../../utils/useClass';
import { useBigCategory } from './utils/useBigCategory';
import AnnexSubCategory from './annex-subCategory';
/**
 * @description: bigCategoryList 注解
 * categoryType 类别。1.大类，2，小类
 * bigCategoryCode 大类code
 * bigCategoryName 大类名称
 * subCategoryList 小类集合
 * templateCode TODO不知道
 */
const props = defineProps({
  bigCategoryItem: {
    type: Object,
    default: () => {
      return {
        bigCategoryName: '',
        bigCategoryItem: [],
      };
    },
  },
  attachmentConfigs: {
      type: Object,
      default: ()=> {}
    },
     /**
   * @description: 上传
   */
  beforeUpload: {
    type: Function,
    default: () => {},
  },
   /**
   * @description: 删除
   */
   beforeDelete: {
    type: Function,
    default: () => {},
  },
});
const { getComponentClass } = useClass();
const emits = defineEmits(['beforeUpload', 'openProview', 'beforeDelete', 'uploadSuccess', 'deleteSuccess']);
const { bigCategoryData, uploadSuccess, deleteSuccess } = useBigCategory(props, emits);
</script>

<style scoped></style>
